package com.example.erpms.controller;

import com.example.erpms.domain.ShoppingBill;
import com.example.erpms.feign.TestingServiceFn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: xwg
 * @CreateDate: 2023/10/7
 */

@RestController
@RequestMapping("/show")
public class ShowController {
    @Autowired
    private TestingServiceFn testingServiceFn;

    @GetMapping("/remoteTime")
    public String getRemoteTime(HttpServletRequest request) {
        String token = request.getHeader("token");
        System.out.println(" token=" + token);

        String time = testingServiceFn.time();
        return "remoteTime " + time;
    }
//    restTemplate spring
//    okhttp3 android
//    axios  javascript

    @PostMapping("/remoteBill")
    public ShoppingBill remoteBill(@RequestBody ShoppingBill shoppingBill) {
        System.out.println("start remote");
        return testingServiceFn.insert(shoppingBill);
    }

}
